



PROCEDURE CreateAPILogMaster:

   define input parameter ip_traceid     as character no-undo.
   define input parameter ip_apiname     as character no-undo.
   define input parameter ip_program     as character no-undo.
   define input parameter ip_cimfile     as character no-undo.
   define input parameter ip_logfile     as character no-undo.
   define input parameter ip_jsonfile    as character no-undo.
   define input parameter ip_billnbr     as character no-undo.
   define input parameter ip_ordernbr    as character no-undo.
   define input parameter ip_detailtable as character no-undo.
   define input parameter ip_lastseq     as integer no-undo.


   for each api_status no-lock where api_status.traceid = ip_traceid
                                 and api_status.billnbr = ip_billnbr
                                 .
   
   find first xxqadapilog_mstr where xxqadapilog_domain = global_domain
                                and xxqadapilog_traceid = api_status.traceid
                                and xxqadapilog_runseq = ip_lastseq
                                and xxqadapilog_billnbr = ip_billnbr
                                no-error.
      
   if not available xxqadapilog_mstr then do:
                
        create xxqadapilog_mstr.
        assign xxqadapilog_traceid           = api_status.traceid
               xxqadapilog_apiname           = ip_apiname
               xxqadapilog_apistatus         = api_status.return_status
               xxqadapilog_logfile           = ip_logfile
               xxqadapilog_cimfile           = ip_cimfile
               xxqadapilog_jsonfile          = ip_jsonfile
               xxqadapilog_rundate           = today
               xxqadapilog_runtime           = time
               xxqadapilog_program           = ip_program
               xxqadapilog_billnbr           = ip_billnbr
               xxqadapilog_qadorder          = ip_ordernbr
               xxqadapilog_detailtable       = ip_detailtable
               xxqadapilog_customfield1      = ""
               xxqadapilog_customfield2      = ""
               xxqadapilog_customfield3      = ""
               xxqadapilog_customfield4      = ""
               xxqadapilog_customfield5      = ""
               xxqadapilog_customfield6      = ""
               xxqadapilog_customfield7      = ""
               xxqadapilog_customfield8      = ""
               xxqadapilog_customfield9      = ""
               xxqadapilog_customfield10     = ""
               xxqadapilog_domain            = global_domain
               xxqadapilog_updatedate        = ?
               xxqadapilog_updatetime        = 0
               xxqadapilog_runseq            = ip_lastseq.
               
               put xxqadapilog_traceid " " xxqadapilog_apistatus skip.
    end. /*   if not available xxqadapilog_mstr then do: */
    
      assign xxqadapilog_message =  if  api_status.message_string <> "" then api_status.message_string + "|" + xxqadapilog_message else "".   
      
      end. /*   for each api_status no-lock. */  
      
 
   
  
   
END.   

